package br.com.mworks.DAO;

import java.sql.*;
import com.microsoft.sqlserver.jdbc.*;

public class Conexao {
	protected Connection conn;
	protected Statement stmt;
	protected PreparedStatement pstmt;
	protected ResultSet rs;
	
	
	protected static String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
	
	
	String connectionString = "jdbc:sqlserver://p7mfdgh5i1.database.windows.net:1433"
			+ ";"
			+ "database=DadosMyWork"
			+ ";"
			+ "user=MyWorkServer@p7mfdgh5i1" + ";" + "password=Mf94055770";
	
	
	protected void open(){
		try {
			Class.forName(driver);
			conn = DriverManager.getConnection(connectionString);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	
	protected void close(){
		if(stmt != null)
			try {
				stmt.close();
				conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
	}
}
